package com.java;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;

import com.java.dao.MasterDao;
import com.java.filter.UserFilter;



@Configuration//配置控制  
@EnableAutoConfiguration//启用自动配置  
@EnableAsync
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ServletComponentScan( basePackages = "com.java.*")  
@ComponentScan( basePackages = "com.java.*") 
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
//	public static void main(String[] args) {
//		new SpringApplicationBuilder().listeners(new ThriftApplicationListener())
//			.sources(Application.class).run(args);
//	}
    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
    	
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new UserFilter(masterDao()));
       // filterRegistrationBean.addUrlPatterns("/");
        return filterRegistrationBean;
    }
    
    @Bean
	public MasterDao masterDao() { 
		return new MasterDao(); 
	}
}